package com.group2.edu.realtime.common.function;/**
 * @Author: Wxs
 * @Description: TODO
 * @Date: 2024/12/16 10:58
 */

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.serializer.SerializeConfig;
import org.apache.flink.api.common.functions.MapFunction;

/**
 * @Author: Wxs
 * @Description: TODO
 * @Date: 2024/12/16 10:58
 */
public class BeanToJsonStrMapFunction<T> implements MapFunction<T,String> {

    @Override
    public String map(T bean) throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setPropertyNamingStrategy(PropertyNamingStrategy.SnakeCase);
        String jsonString = JSONObject.toJSONString(bean, config);
        return jsonString;
    }
}
